package com.apes.fn.server.productRequire;

import com.apes.fn.mdm.purchase.PurchasingGroup;
import com.apes.fn.tms.model.Site;
import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.scm.masterdata.enumeration.model.Enumeration;
import com.apes.scm.masterdata.party.model.PartyRole;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = RequireInquireItem.CONST_TABLE_NAME)
public class RequireInquireItem extends BaseModel {

    public static final String CONST_TABLE_NAME = "stock_require_inquire_item";

    @Id
    @Column(name = "id")
    @ApesGenerator(code = CONST_TABLE_NAME, padding = 1, name = "要货询价明细")
    private String id;


    @ManyToOne(optional = false)
    @JoinColumn(name = "require_item_id", referencedColumnName = "id")
    @Comment("要货单明细")
    private ProductRequireItem requireItem;


    @Column(name = "commodity_inquiry_order_id")
    @Comment("询价单号")
    private String commodityInquiryOrderId;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "supplier_id", referencedColumnName = "id")
    @Comment("供应商编码")
    private PartyRole supplier;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "site_id", referencedColumnName = "id")
    @Comment("站点")
    private Site site;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "purchasing_group_id", referencedColumnName = "id")
    @Comment("采购组")
    private PurchasingGroup purchasingGroup;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "source_state", referencedColumnName = "id" )
    @Comment("货源状态")
    private Enumeration sourceState;

    @Column(name = "channel_type", columnDefinition = "number(2)")
    @Comment("渠道类型")
    private Integer channelType; // 1:价格前置、2:新平台询价、3：询价执行表

    @Column(name = "sp_id")
    @Comment("供应商平台商品ID")
    private String spId;

    @Column(name = "offer_id", length = 4000)
    @Comment("报价ID")
    private String offerId;

    @Column(name = "unique_value", length = 4000)
    @Comment("唯一值")
    private String uniqueValue;

}
